package com.asr.testclient.model;

import com.google.gson.Gson;

/**
 * 客户端消息数据模型
 * 用于构建发送到ASR服务器的JSON消息
 */
public class ClientMessage {
    private String type;
    private String file_data;
    private String filename;

    private static final Gson gson = new Gson();

    public ClientMessage(String type, String fileData, String filename) {
        this.type = type;
        this.file_data = fileData;
        this.filename = filename;
    }

    public ClientMessage(String type, String fileData) {
        this(type, fileData, null);
    }

    public String getType() {
        return type;
    }

    public String getFileData() {
        return file_data;
    }

    public String getFilename() {
        return filename;
    }

    /**
     * 将消息对象序列化为JSON字符串
     * @return JSON格式的字符串
     */
    public String toJson() {
        return gson.toJson(this);
    }
}
